const mysql = require('mysql')
dbconfig = {
  config: {
    connectionLimit: 10,
    host: 'localhost',
    port: "3306",
    user: 'root',
    password: 'mWXS19971222@.',
    database: 'bookstore',
  },
  //连接数据库 pool
  sqlConnect: function (sql, sqlArr, callback) {
    var pool = mysql.createPool(this.config)
    pool.getConnection((err, conn) => {
      if (err) {
        console.log(err);
        console.log('connection is fail');
        return;
      }
      //事件驱动回调
      conn.query(sql, sqlArr, callback);
      //释放连接
      conn.release();
    })
  }
}
module.exports = dbconfig;